/*
 * @lc app=leetcode.cn id=73 lang=typescript
 *
 * [73] 矩阵置零
 */

// @lc code=start
/**
 Do not return anything, modify matrix in-place instead.
 */
function setZeroes(matrix: number[][]): void {
    const m = matrix.length;
    const n = matrix[0].length;
    const mArr = new Array(m).fill(false);
    const nArr = new Array(n).fill(false);

    for (let i = 0; i < m; i++) {
        for (let j = 0; j < n; j++) {
            if (matrix[i][j] === 0) {
                mArr[i] = nArr[j] = true;
            }
        }
    }

    for (let i = 0; i < m; i++) {
        for (let j = 0; j < n; j++) {
            if (mArr[i] || nArr[j]) {
                matrix[i][j] = 0;
            }
        }
    }
    // console.log(matrix)

};

// setZeroes([[0, 1, 2, 0], [3, 4, 5, 2], [1, 3, 1, 5]])

// @lc code=end

